#ifndef MOUSEPOSITION_H
#define MOUSEPOSITION_H

#include <QObject>
#include <QPoint>
#include <QCursor>

class MousePosition : public QObject
{
    Q_OBJECT
    // 暴露全局X、Y坐标给QML
    Q_PROPERTY(int globalX READ globalX NOTIFY globalPositionChanged)
    Q_PROPERTY(int globalY READ globalY NOTIFY globalPositionChanged)

public:
    explicit MousePosition(QObject *parent = nullptr) : QObject(parent) {}

    // 获取当前全局X坐标
    int globalX() const { return QCursor::pos().x(); }
    // 获取当前全局Y坐标
    int globalY() const { return QCursor::pos().y(); }

signals:
    // 位置变化时触发（供QML更新）
    void globalPositionChanged();
};

#endif // MOUSEPOSITION_H

